// custom-tab-bar/index.js

Component({
    /**
     * 组件的属性列表
     */
    properties: {


    },

    /**
     * 组件的初始数据
     */
    data: {
        url1:"../img/home.png",
        url2:"/img/music.png",
        url3:"/img/quanzi.png",
        url4:"/img/atm.png",
        wenzi:"wenzi"
    },
    attached() {
    },

    /**
     * 组件的方法列表           自定义方法全部写在method里
     */
    methods: {

         /**获取当前路由的方法 */
        getU:function(){
            let url=getCurrentPages()[getCurrentPages().length-1].route
            if(url=="pages/test/test"){
                this.setData({
                    url1:"/img/home1.png",
                    
                })
            }else if(url=="pages/content/content"){
                this.setData({
                    url2:"/img/music2.png",
                })
            }else if(url=="pages/range/range"){
                this.setData({
                    url3:"/img/quanzi1.png",
                    
                })
            }else if(url=="pages/user/user"){
                this.setData({
                    url4:"/img/atm1.png",
                    
                })
            }
           
        },
        ToHome(){
            wx.switchTab({
              url: '/pages/test/test',
            })
            this.getU()
        },
        ToMessage(){
            wx.switchTab({
              url: '/pages/content/content',
            })
            this.getU()
        },
        To(){
            wx.switchTab({
              url: '/pages/range/range',
            })
            this.getU()
        },
        ToMine(){
            wx.switchTab({
              url: '/pages/user/user',
            })
           this.getU()
        },
        post(){
            console.log("post")
            wx.navigateTo({
              url: '/pages/post/post',
            })
        }

    }
})
